﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:local="clr-namespace:EIA.SLClient.ProjectManage.Progress"
	xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
	xmlns:EIA_SLClient_Utility="clr-namespace:EIA.SLClient.Utility;assembly=EIA.SLClient.Utility"
	xmlns:EIA_SLClient_Utility_Behaviors="clr-namespace:EIA.SLClient.Utility.Behaviors;assembly=EIA.SLClient.Utility"
	xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
	mc:Ignorable="d"
	x:Class="EIA.SLClient.ProjectManage.Progress.DelayApplyView"
	d:DesignWidth="360" d:DesignHeight="480">
	<UserControl.Resources>
		<local:DelayApplyViewModel x:Key="DelayApplyViewModelDataSource" />
		<DataTemplate x:Key="OptDataTemplate">
        	<StackPanel d:DesignWidth="100" Orientation="Horizontal">
                <HyperlinkButton Content="编辑" CommandParameter="{Binding}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="8,0" Visibility="{Binding ApproveState, ConverterParameter=f, Converter={StaticResource NotNull2VisibilityConverter}}">
                    <EIA_SLClient_Utility:BindingHelper.AncestorBinding>
                        <EIA_SLClient_Utility:AncestorBinding TargetPath="Command" AncestorPath="DataContext.UpdateItemCommand" AncestorTypeName="DataGrid"/>
                    </EIA_SLClient_Utility:BindingHelper.AncestorBinding>
                </HyperlinkButton>
                <HyperlinkButton Content="删除" CommandParameter="{Binding}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="8,0" Visibility="{Binding ApproveState, ConverterParameter=f, Converter={StaticResource NotNull2VisibilityConverter}}">
                    <EIA_SLClient_Utility:BindingHelper.AncestorBinding>
                        <EIA_SLClient_Utility:AncestorBinding TargetPath="Command" AncestorPath="DataContext.DeleteItemCommand" AncestorTypeName="DataGrid"/>
                    </EIA_SLClient_Utility:BindingHelper.AncestorBinding>
                </HyperlinkButton>
            </StackPanel>
		</DataTemplate>
	</UserControl.Resources>

	<Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource DelayApplyViewModelDataSource}}">
		<i:Interaction.Triggers>
			<i:EventTrigger>
				<ei:CallMethodAction TargetObject="{Binding Mode=OneWay}" MethodName="OnLoad"/>
			</i:EventTrigger>
		</i:Interaction.Triggers>
		<Grid Background="#FFD4D4D4" Margin="8">
			<Grid.RowDefinitions>
				<RowDefinition Height="32"/>
				<RowDefinition/>
			</Grid.RowDefinitions>
			<TextBlock HorizontalAlignment="Left" Margin="8,8,0,8" TextWrapping="Wrap" Text="项目延期记录" d:LayoutOverrides="Height"/>
			<sdk:DataGrid Grid.Row="1" BorderThickness="1,0,1,1" BorderBrush="LightGray" ItemsSource="{Binding DelayApplyCollection}">
				<sdk:DataGrid.Columns>
					<sdk:DataGridTextColumn Header="原预计完成时间" Binding="{Binding OrginalScheduled, StringFormat='yyyy-MM-dd'}"/>
					<sdk:DataGridTextColumn Header="延期天数" Binding="{Binding DlyDays}"/>
					<sdk:DataGridTextColumn Header="批准状态" Binding="{Binding ApproveState, ConverterParameter=XMYQSPZT, Converter={StaticResource DicItemConverter}}"/>
					<sdk:DataGridTemplateColumn Header="操作" CellTemplate="{StaticResource OptDataTemplate}"/>
				</sdk:DataGrid.Columns>
			</sdk:DataGrid>
			<HyperlinkButton Content="申请延期" HorizontalAlignment="Left" Margin="88,8,0,8" d:LayoutOverrides="Height" Command="{Binding InsertItemCommand}"/>
			<HyperlinkButton Content="重新载入" HorizontalAlignment="Right" Margin="0,8,8,8" Command="{Binding RetrieveItemsCommand}" d:LayoutOverrides="Height"/>
		</Grid>
		<local:DelayApplyEditView d:LayoutOverrides="Width"/>
	</Grid>
</UserControl>
